#include <iostream>
#include <fstream>
#include <ctime>
 
using namespace std;
 
int numbers[5000];
 
void bubbleSort(int arr[]) 
{
    for (size_t v = 0; v < 4999; v++)
    {
        for (int j = 0; j < 4999 - v; j++)
        {
            if (arr[j] > arr[j + 1]) 
            {
                int n = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = n;
            }
            
        }
    }
}
 
void readFile(string fileName) 
{
    fstream file(fileName);
    if (file.is_open())
    {
        for (size_t i = 0; i < 5000; i++)
        {
            file >> numbers[i];
        }
        clock_t start = clock();
        bubbleSort(numbers);
        clock_t end = clock();
        cout << fileName << " " << end - start << " milliseconds" << endl;
    }
    else cout << "Fail open: " << fileName << endl;
    file.close();
}
 
int main()
{
    readFile("m1_sorted.txt");
    readFile("m2_reverse.txt");
    readFile("m3_shuffle.txt");
}
